<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          icon="el-icon-refresh"
          size="mini"
          @click="showInfoList"
        ></el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="infos">
      <el-table-column label="目标地址" prop="destUrl" align="center" />
      <el-table-column label="类型" prop="type" align="center" />
      <el-table-column label="匹配前缀" prop="srcPrefix" align="center" />
      <el-table-column label="源地址" prop="srcPrefix" align="center">
        <template slot-scope="scope">{{ srcUrl(scope.row) }}</template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { getGatewayProxyInfo } from "@/api/console";
import { getQueryObject } from "@/utils/index";
export default {
  name: "gateway",
  data() {
    return {
      loading: false,
      infos: [],
    };
  },
  created() {
    this.showInfoList();
  },
  methods: {
    showInfoList() {
      const params = getQueryObject();
      const deployName = params.deployName;
      const groupName = params.groupName;
      const workerName = params.workerName;
      const index = params.index;
      this.loading = true;
      getGatewayProxyInfo(groupName, workerName, index, deployName)
        .then((res) => {
          this.infos = res.data;
          this.loading = false;
        })
        .catch((msg) => {
          this.loading = false;
        });
    },
    srcUrl(row) {
      return (
        row.type +
        "://" +
        row.gatewayHost +
        ":" +
        row.gatewayPort +
        "/" +
        row.srcPrefix
      );
    },
  },
};
</script>